<style lang="scss" scoped>
    @import '@/assets/css/index';
	
	.iconImg{
		width: 100%;
		text-align: center;
		margin-top: 80px;
		overflow: hidden;
		img{
			width: 140px !important;
			height: 140px;
		}
	}
    .verification{
        @include page();
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-around;
		text-align: center;
		.result{
			margin-top: 30px;
			color: #16D17B;
			font-size: 1.6rem;
		}
		.desc{
			margin-top: 10px;
			// color:$color2;
			.text{
				color: #16D17B;
			}
		}
		.btnBox{
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 1.6rem;
			margin-top: 0rem;
			.btn1{
				flex: 1;
				margin-right: 1rem;
			}
			.btn2{
				flex: 1;
				margin-left: 1rem;
			}
		}
    }
</style>
<template>
  <div class="verification">
	  <div v-if="result=='核销成功'">
		  <div  class="iconImg">
			  <img src="../../assets/img/success.png">
		  </div>
		  <div>
			  <div class="result">核销成功</div>
		  </div>
	  </div>
	  <div v-else-if="result=='核销中...'">
	  		 <div class="result">{{result}}</div>
	  </div>
	  <div  v-else>
		  <did  class="iconImg">
		  		 <img src="../../assets/img/fail.png">
		  </did>
		 <div>
		 	<div class="result">{{result}}</div>
		 </div>
	  </div>
	  <div class="btnBox">
		<div class="btn1">
			<van-button round plain type="info" style="width: 100%;" @click="toViewReplace('/case')">返回首页</van-button>
		</div>
		<div class="btn2">
			<van-button round block type="info" style="width: 100%;" @click="scanQRCode">继续核销</van-button>
		</div>
	  </div>
  </div>
</template>

<script>
	import { myMixins } from "@/assets/js/mixins.js";
export default {
    name: 'Verification',
	mixins: [myMixins],
    data () {
        return {
            // activity_id:'',
            b_openid:'',
            openid:'',
            order_id:'',
			result:'核销中...'
        }
    },
    mounted () {
        const _this = this
        // _this.activity_id = _this.$route.params.activity_id;
		// alert(_this.$route.query.params)
        const params = JSON.parse(_this.$route.query.params)
        _this.b_openid = params.openid;
        _this.openid = localStorage.getItem('COPENID');
        _this.order_id = params.order_id;
		// alert("_this.$route.query.params:"+_this.$route.query.params)
  //       alert('_this.openid:'+_this.openid)
  //       alert('_this.order_id:'+_this.order_id)
        if(_this.openid&&_this.order_id){
        	_this.verificationItem()
        }
    },
    methods: {
        // 核销接口
        verificationItem() {
            let params = {
                openid: this.openid,
                order_id: this.order_id
            }
			// alert(JSON.stringify(params))
            console.log(params, 'paramsparams')
            this.$request.getUpdateWriteoff(params).then(res=>{
                console.log(params, 'paramsparams111')
                if(res.data == 2) {
					this.result = '请勿重复核销'
                }else if(res.data == 1) {
					this.result = '核销成功'
                }else if (res.data == 3) {
					this.result = '您不是核销人员'
                }else if (res.data == 4) {
					this.result = '发货商品,不在此处核销'
                }
            })
        }
    }
}
</script>